package service.impl;

import dao.IOrderDao;
import dao.impl.OrderDaoImpl;
import pojo.OrderDetail;
import pojo.OrderGoodsInfo;
import service.IOrderService;

import java.util.List;

public class OrderServiceImpl implements IOrderService {
    private final IOrderDao orderDao = new OrderDaoImpl();

    /**
     * 向订单详情表中添加数据
     *
     * @param orderDetail
     * @return
     */
    @Override
    public boolean addToOrderDetail(OrderDetail orderDetail) {
        return orderDao.addToOrderDetail(orderDetail);
    }

    /**
     * 向订单-商品映射表中添加数据
     *
     * @param orderGoodsInfo
     * @return
     */
    @Override
    public boolean addToOrderGoodsInfo(OrderGoodsInfo orderGoodsInfo) {
        return orderDao.addToOrderGoodsInfo(orderGoodsInfo);
    }

    /**
     * 根据订单id从订单详情表中查询数据
     *
     * @param id
     * @return
     */
    @Override
    public OrderDetail queryOrderDetailById(String id) {
        return orderDao.queryOrderDetailById(id);
    }


    /**
     * 根据订单id从订单-商品映射表中查询数据
     *
     * @param oid
     * @return
     */
    @Override
    public List<OrderGoodsInfo> queryOrderGoodsInfosById(String oid) {
        return orderDao.queryOrderGoodsInfosById(oid);
    }

    /**
     * 根据用户id查询订单
     *
     * @param uid
     * @return
     */
    @Override
    public List<OrderDetail> queryOrderDetailsByUid(int uid) {
        return orderDao.queryOrderDetailsByUid(uid);
    }
}
